;Void ScanLineSetColorARGB32WithColorAlpha(
;                Pixel* dst, Int32 stride, Pixel srcColor)
; R0 = dst
; R1 = stride
; R2 = srcColor
; r3 = 0xFF - srcColor.a
; R4 = *dst

        AREA sample, CODE, READONLY
   EXPORT  ScanLineSetColorARGB32WithColorAlpha
ScanLineSetColorARGB32WithColorAlpha


	STMFD	SP!, {R4-R8, LR}

	MOV     R3, R2, LSR #24              ;R3: srcColor.a
    RSB     R3, R3, #255                ;R3: 255 - srcColor.a

	LDR     R4, [R0]
	MOV	    LR, #16711680
	ADD	    LR, LR, #255                ;LR: 00FF00FF

_ScanLineSetColorARGB32WithColorAlpha_Loop

    AND     R5, LR, R4                  ;R5: [0, d2, 0, d0]
    MUL     R7, R5, R3                  ;R7: [d2 * (255 - alpha), d0 * (255 - alpha)]
    AND     R6, LR, R4, LSR #8          ;R6: [0, d3, 0, d1]
	SUBS	R1, R1, #1

    MUL     R8, R6, R3                  ;R8:[d3 * (255 - alpha), d1 * (255 - alpha)]
	LDRNE   R4, [R0, #4]

    AND     R5, LR, R7, LSR #8          ;R7: [0, (d2 * (255 - alpha))>> 8, 0, (d0 * (255 - alpha))>>8]
    AND     R6, LR, R8, LSR #8          ;R8: [0, (d3 * (255 - alpha))>> 8, 0, (d1 * (255 - alpha))>>8]

    ORR     R5, R5, R6, LSL #8          ;[(d3 * (255 - alpha))>> 8, d2 * (255 - alpha))>> 8, (d1 * (255 - alpha))>>8, (d0 * (255 - alpha))>>8]
    ADD     R5, R2, R5                  ;srcColor + dst * (255 -a)
    STR     R5, [R0], #4

	BNE 	_ScanLineSetColorARGB32WithColorAlpha_Loop

_ScanLineSetColorARGB32WithColorAlpha_End
	LDMFD	SP!, {R4-R8, PC}

    END
